home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2.sit / Raven 1.2 / Source / Foundation / Common / ZProfiler.h < prev    next >
Text File  |  1997-09-06  |  2KB  |  114 lines

  1. /*
  2.  *  File:       ZProfiler.h
  3.  *  Summary:       Stack based class used to profile blocks of code.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996-1997 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <3>     9/05/97    JDJ        Added IsEnabled.
  12.  *         <2>     7/27/97    JDJ        Added Enable and Disable methods.
  13.  *         <1>    12/05/96    JDJ        Created
  14.  */
  15.  
  16. #pragma once
  17.  
  18. #include <string>
  19.  
  20. #if    __profile__
  21. #include <Profiler.h>
  22. #endif
  23.  
  24.  
  25. //================================================================================
  26. // class TProfiler
  27. //================================================================================
  28. class TProfiler {
  29.  
  30. //-----------------------------------
  31. //    Initialization/Destruction
  32. //
  33. public:
  34.                         ~TProfiler();
  35.                        
  36.                         TProfiler(const string& fileName, short numFunctions = 2000, short stackDepth = 75);
  37.                         // Destructor will ASSERT if numFunctions or stackDepth isn't large enough.
  38.  
  39. //-----------------------------------
  40. //    API
  41. //
  42. public:
  43.             bool        IsEnabled() const;
  44.  
  45.             void        Enable();
  46.                         // Turns profiling on.
  47.  
  48.             void        Disable();
  49.                         // Turns profiling off.
  50.  
  51. protected:
  52. #if    __profile__
  53.     string        mFileName;
  54.     int            mNumFunctions;
  55.     int            mStackSize;
  56.     long        mEnableCount;
  57.     
  58.     static bool    msConstructed;
  59. #endif
  60. };
  61.  
  62.  
  63. //================================================================================
  64. // class TProfileEnabler
  65. //================================================================================
  66. class TProfileEnabler {
  67.  
  68. public:
  69.                        ~TProfileEnabler();
  70.                        
  71.                         TProfileEnabler();
  72.  
  73. protected:
  74. #if    __profile__
  75.     bool    mWasEnabled;
  76. #endif
  77. };
  78.  
  79.  
  80. //================================================================================
  81. // Inlines
  82. //================================================================================
  83. #if !__profile__
  84. inline TProfiler::~TProfiler()
  85. {
  86. }
  87.            
  88. inline TProfiler::TProfiler(const string&, short, short)
  89. {
  90. }
  91.  
  92. inline bool TProfiler::IsEnabled() const            
  93. {
  94.     return false;
  95. }
  96.  
  97. inline void    TProfiler::Enable()
  98. {
  99. }
  100.  
  101. inline void    TProfiler::Disable()
  102. {
  103. }
  104.  
  105. inline TProfileEnabler::~TProfileEnabler()
  106. {
  107. }
  108.  
  109. inline TProfileEnabler::TProfileEnabler()
  110. {
  111. }
  112. #endif    // !__profile__
  113.  
  114.